package com.fwmagic.spark.ml.tfidf

import java.util

import com.hankcs.hanlp.HanLP
import com.hankcs.hanlp.dictionary.py.Pinyin
import com.hankcs.hanlp.seg.common.Term

/**
 * 分词算法
 */
object HanLPDemo {
  def main(args: Array[String]): Unit = {
    val str = "我有一头小毛驴我从来也不骑，有一天我心血来潮骑着去赶集"

    val terms: util.List[Term] = HanLP.segment(str)

    import scala.collection.JavaConversions._

    terms.foreach(term =>{
      println(term.word)
    })


    val pinyins: util.List[Pinyin] = HanLP.convertToPinyinList(str)
    pinyins.foreach(pinyin => println(pinyin.getPinyinWithToneMark))

  }

}
